from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Atom1Feed, RssUserland091Feed

from assets.models import Asset

class LatestEntriesFeed(Feed):
    feed_type = RssUserland091Feed
    title = "DAMN recent assets"
    link = "/feed/"
    description = "Updates on assets"

    def items(self):
        return Asset.objects.order_by('-stamp')[:5]

    def item_title(self, item):
        return item.id

    def item_description(self, item):
        return item.subName
    
    def item_link(self, item):
        return '/assets/'+str(item.id)
    
    def item_author_name(self, item):
        return item.file.author
        
    def item_enclosure_mime_type(self, item):
        return 'image/png'
    
    def item_enclosure_length(self, item):
        return 1
        
    def item_enclosure_url(self, item):
        return '/assets/%s/transcode/?format=image/png&sizex=128&sizey=128'%(item.id)
